<!--
 * 地图
 * @author junpeng.li
 * @date 2024-11-26 16:26
-->
<script setup lang="ts" name="Map">
import useMap from './Map'

const map = useMap({
  defaultZoom: 12,
  defaultCenter: {
    lng: 116.59454,
    lat: 40.07677
  },
  minZoom: 2,
  maxZoom: 18
})

const { currentZoom, currentPointPosition, currentRotation, isMoving } = map

defineExpose({
  map
})
</script>

<template>
  <div
    :id="map.id"
    class="map-wrapper"
  >
    <div class="bottom-toolbar">
      <span>当前级别：{{ currentZoom.toFixed(0) }}</span>
      <span style="width: 130px">经度：{{ currentPointPosition.lng.toFixed(5) }}</span>
      <span style="width: 130px">纬度：{{ currentPointPosition.lat.toFixed(5) }}</span>
      <span>当前的旋转角度：{{ currentRotation }}</span>
      <span>漫游状态：{{ isMoving ? '是' : '否' }}</span>
    </div>
  </div>
</template>

<style scoped lang="scss">
.map-wrapper {
  width: 100%;
  height: 100%;
  background-color: gray;
  position: relative;

  .bottom-toolbar {
    z-index: 1;
    width: 100%;
    height: 36px;
    position: absolute;
    left: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    font-size: 14px;
    padding: 0 10px;
    background-color: rgba(0, 0, 0, 0.4);
    color: #f2f2f2;
    gap: 20px;
  }
}
</style>
